import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/pages/layout/Layout'
import store from '../store';

Vue.use(Router)

export default new Router({
  // mode: 'history', //去掉地址栏的#号
  routes: [
    {
      path: '/login',
      name: 'AIBox总后台管理系统',
      component: (resolve) => require(['@/pages/login/Login'], resolve),
      meta: {
        title: 'AIBox总后台管理系统'
      }
    },
    {
      path: '/',
      name: '主页面',
      component: Layout,
      redirect: !store.state.loginToken ? '/login' : '/home',
      children: [
        {
          path: 'home',
          name: '首页',
          component: (resolve) => require(['@/pages/home/Home'], resolve),
          meta: {
            title: '首页',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/sellorder',
          name: '销售订单',
          component: (resolve) => require(['@/pages/orderAdmin/SellOrder'], resolve),
          meta: {
            title: '销售订单',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/sellorder/selldetails',
          name: '销售订单详情',
          component: (resolve) => require(['@/pages/orderAdmin/SellDetails'], resolve),
          meta: {
            title: '销售订单详情',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/aftersaleindent',
          name: '售后订单',
          component: (resolve) => require(['@/pages/orderAdmin/AfterSaleIndent'], resolve),
          meta: {
            title: '售后订单',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/aftersaleindent/aftersaledetails',
          name: '售后订单详情',
          component: (resolve) => require(['@/pages/orderAdmin/AfterSaleDetails'], resolve),
          meta: {
            title: '售后订单详情',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/abnormalorders',
          name: '异常订单',
          component: (resolve) => require(['@/pages/orderAdmin/AbnormalOrders'], resolve),
          meta: {
            title: '异常订单',
            requireLogin: true
          }
        },
        {
          path: 'home/orderadmin/abnormalorders/abnormaldetails',
          name: '异常订单详情',
          component: (resolve) => require(['@/pages/orderAdmin/AbnormalDetails'], resolve),
          meta: {
            title: '异常订单详情',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/allgoods',
          name: '总商品库',
          component: (resolve) => require(['@/pages/goodsAdmin/Allgoods'], resolve),
          meta: {
            title: '总商品库',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/allgoods/goodsnew',
          name: '新建商品',
          component: (resolve) => require(['@/pages/goodsAdmin/GoodsNew'], resolve),
          meta: {
            title: '新建商品',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/allgoods/allgoodsedit',
          name: '编辑商品',
          component: (resolve) => require(['@/pages/goodsAdmin/AllGoodsEdit'], resolve),
          meta: {
            title: '编辑商品',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/goodsclassify',
          name: '商品分类',
          component: (resolve) => require(['@/pages/goodsAdmin/GoodsClassify'], resolve),
          meta: {
            title: '商品分类',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/goodsclassify/goodsnewclassify',
          name: '新建商品分类',
          component: (resolve) => require(['@/pages/goodsAdmin/GoodsNewclassify'], resolve),
          meta: {
            title: '新建商品分类',
            requireLogin: true
          }
        },
        {
          path: 'home/goodsadmin/arithdiscern',
          name: '算法识别码',
          component: (resolve) => require(['@/pages/goodsAdmin/ArithDiscern'], resolve),
          meta: {
            title: '算法识别码',
            requireLogin: true
          }
        },
        {
          path: 'home/stockinquiry',
          name: '库存查询',
          component: (resolve) => require(['@/pages/stockInquiry/StockInquiry'], resolve),
          meta: {
            title: '库存查询',
            requireLogin: true
          }
        },
        {
          path: 'home/useradmin',
          name: '用户管理',
          component: (resolve) => require(['@/pages/userAdmin/UserAdmin'], resolve),
          meta: {
            title: '用户管理',
            requireLogin: true
          }
        },
        {
          path: 'home/useradmin/expenserecord',
          name: '消费记录',
          component: (resolve) => require(['@/pages/userAdmin/ExpenseRecord'], resolve),
          meta: {
            title: '消费记录',
            requireLogin: true
          }
        },
        {
          path: 'home/agentadmin',
          name: '代理商管理',
          component: (resolve) => require(['@/pages/agentAdmin/AgentAdmin'], resolve),
          meta: {
            title: '代理商管理',
            requireLogin: true
          }
        },
        {
          path: 'home/facilityadmin/facilityadminson',
          name: '设备管理',
          component: (resolve) => require(['@/pages/facilityAdmin/FacilityAdmin'], resolve),
          meta: {
            title: '设备管理',
            requireLogin: true
          }
        },
        {
          path: 'home/facilityadmin/repairsfacility',
          name: '报修设备',
          component: (resolve) => require(['@/pages/facilityAdmin/RepairsFacility'], resolve),
          meta: {
            title: '报修设备',
            requireLogin: true
          }
        },
        {
          path: 'home/facilityadmin/keepalive',
          name: '保活信息',
          component: (resolve) => require(['@/pages/facilityAdmin/KeepAlive'], resolve),
          meta: {
            title: '保活信息',
            requireLogin: true
          }
        },
        {
          path: 'home/containerlog',
          name: '货柜日志',
          component: (resolve) => require(['@/pages/containerLog/ContainerLog'], resolve),
          meta: {
            title: '货柜日志',
            requireLogin: true
          }
        },
        {
          path: 'home/financeadmin/residualadmin',
          name: '余额管理',
          component: (resolve) => require(['@/pages/financeAdmin/ResidualAdmin'], resolve),
          meta: {
            title: '余额管理',
            requireLogin: true
          }
        },
        {
          path: 'home/financeadmin/cashmanagement',
          name: '提现管理',
          component: (resolve) => require(['@/pages/financeAdmin/Cashmanagement'], resolve),
          meta: {
            title: '提现管理',
            requireLogin: true
          }
        },
        {
          path: 'home/financeadmin/billadmin',
          name: '账单管理',
          component: (resolve) => require(['@/pages/financeAdmin/BillAdmin'], resolve),
          meta: {
            title: '账单管理',
            requireLogin: true
          }
        },
        {
          path: 'home/accessadmin/peopleadmin',
          name: '人员管理',
          component: (resolve) => require(['@/pages/accessAdmin/PeopleAdmin'], resolve),
          meta: {
            title: '人员管理',
            requireLogin: true
          }
        },
        {
          path: 'home/accessadmin/roleadmin',
          name: '角色管理',
          component: (resolve) => require(['@/pages/accessAdmin/RoleAdmin'], resolve),
          meta: {
            title: '角色管理',
            requireLogin: true
          }
        },
        {
          path: 'home/accessadmin/roleadmin/roleadd',
          name: '新增角色',
          component: (resolve) => require(['@/pages/accessAdmin/RoleAdd'], resolve),
          meta: {
            title: '新增角色',
            requireLogin: true
          }
        },
        {
          path: 'home/accessadmin/roleadmin/roleedit',
          name: '编辑角色',
          component: (resolve) => require(['@/pages/accessAdmin/RoleEdit'], resolve),
          meta: {
            title: '编辑角色',
            requireLogin: true
          }
        },
      ]
    },
    // 输入不存在地址跳转首页
    {
      path: '*',
      name: '输入不存在地址跳转首页',
      redirect: '/'
    },
  ]
})